package qqserver.service;

import qqcommon.Message;

import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 王艺锡
 * @version 1.0
 * 该类用于储存离线消息
 */
public class OfflineMessageService {
    private static ConcurrentHashMap<String, ArrayList<Message>> chm = new ConcurrentHashMap<>();

    //获取ConcurrentHashMap集合
    public static ConcurrentHashMap<String, ArrayList<Message>> getChm() {
        return chm;
    }
    //通过receiverId获取对应ArrayList
    public static ArrayList<Message> getArrayList(String receiverId){
        return chm.get(receiverId);
    }

    //添加
    public static void addArrayList(String receiverId,ArrayList<Message> arrayList){
        chm.put(receiverId,arrayList);
    }

    //删除
    public static void removeArrayList(String receiverId){
        chm.remove(receiverId);
    }
}
